:root {
    --primary-glass: #4DA2FF --bs-btn-active-bg: #009e8c !important;
    --dark-glass: rgba(40, 40, 40, 0.4);
    --light-glass: transparent;
    --light-glass-border: rgba(255, 255, 255, 0.2);
    --dark: #0a0a0a;
    --darker: #000;
    --card: #1E1E1E;
    --yuna: #009e8c;
    --transition-speed: 0.4s;
    --glass-blur: blur(6px) saturate(200%);
}

*:not(i) {
    font-family: "yukiarimo", sans-serif !important;
}

/* Light mode variables */
@media (prefers-color-scheme: light) {
    :root {
        --dark-glass: rgba(220, 220, 220, 0.4);
        --light-glass: rgba(50, 50, 50, 0.2);
        --light-glass-border: rgba(0, 0, 0, 0.2);
        --dark: #f5f5f7;
        --darker: #ffffff;
        --card: #ffffff;
    }
    body {
        color: #1d1d1f;
        background: #f5f5f7 !important;
    }
    .menu-button {
        color: #1d1d1f !important;
    }
    #messageInput {
        color: #000 !important;
    }
}

@font-face {
    font-family: "yukiarimo";
    src: url("/static/fonts/yukiarimo.woff") format("woff");
    font-style: normal;
    font-display: auto;
    font-weight: normal;
}

body {
    background: #1E1E1E;
    color: #f5f5f7;
    font-family: 'yukiarimo', sans-serif;
    background-image: url('/static/img/yuna-girl.webp');
    background-size: fit;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    overflow-x: hidden;
}

* {
    cursor: url('/static/img/cursor.png') 0 0, auto !important;
}

*::-webkit-scrollbar {
    display: none;
    overscroll-behavior: none;
}

.top-menu {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: none;
    gap: 10px;
}

.top-menu.visible {
    display: flex;
}

.menu-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--dark-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--light-glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-speed) ease, background-color var(--transition-speed) ease;
    color: #f5f5f7;
}

.menu-button:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(150, 201, 255, 0.055),
        inset 0 0 5px rgba(255, 255, 255, 0.3);
    transition: transform var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1),
        background-color var(--transition-speed) ease,
        box-shadow var(--transition-speed) ease;
}

.yuna-avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 2px solid var(--light-glass-border);
    position: fixed;
    top: 20px;
    left: 20px;
    transition: transform var(--transition-speed);
    z-index: 1000;
}

.chat-container {
    max-width: 1200px;
    margin: 100px auto 120px;
    /* Increased bottom margin */
    padding: 20px;
}

.message {
    max-width: 70%;
    margin: 15px;
    padding: 12px 18px;
    border-radius: 22px;
    animation: fadeIn 0.5s ease-out;
    position: relative;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px 0px rgba(255, 255, 255, 0.2) inset, 0 0 10px 2px rgba(0, 0, 0, 0.2) inset;
}

.message-user {
    background: rgba(0, 158, 140, 0.8);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    margin-left: auto;
    border-radius: 22px 22px 5px 22px;
    white-space: pre-line;
}

.message-ai {
    background: rgba(80, 80, 80, 0.4);
    margin-right: auto;
    border-radius: 22px 22px 22px 5px;
    white-space: pre-line;
}

.message-actions {
    position: absolute;
    bottom: -28px;
    right: 5px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(-10px);
}

.message:hover .message-actions {
    opacity: 1;
    transform: translateY(0);
}

.action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--dark-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: white;
    border: 1px solid var(--light-glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
    font-size: 12px;
    padding: 0;
}

.action-btn:hover {
    transform: scale(1.1);
    background-color: rgba(255, 255, 255, 0.2);
}

.delete-btn:hover {
    background-color: rgba(220, 53, 69, 0.6);
}

.regenerate-btn:hover {
    background-color: rgba(13, 110, 253, 0.6);
}

.modal-custom,
.modal-content {
    background: rgba(20, 20, 20, 0.5);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-radius: 24px;
    border: 1px solid var(--light-glass-border);
}

.call-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    padding: 20px;
}

.video-frame {
    flex: 1;
    background: var(--dark);
    border-radius: 15px;
    overflow: hidden;
    margin: 10px;
    position: relative;
}

.video-frame img,
.video-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.controls-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-glass);
    border-radius: 30px;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.control-button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: var(--light-glass);
    color: white;
    transition: transform var(--transition-speed), background-color var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-button:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
}

.diary-card {
    background: var(--dark-glass);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--light-glass-border);
}

.popup-panel {
    position: fixed;
    top: 0;
    right: -100vw;
    /* Use vw for full viewport width */
    width: 100%;
    max-width: 100%;
    height: 100vh;
    background: rgba(25, 25, 25, 0.5);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    transition: transform var(--transition-speed) cubic-bezier(0.25, 1, 0.5, 1);
    padding: 20px;
    z-index: 1050;
    overflow-y: auto;
    border-left: 1px solid var(--light-glass-border);
}

.popup-panel.active {
    transform: translateX(-100%);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1040;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.overlay.active {
    display: block;
    opacity: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.floating-audio-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    height: 200px;
    background: var(--dark-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--light-glass-border);
    border-radius: 15px;
    display: none;
    flex-direction: column;
    z-index: 1060;
}

.floating-audio-window.active {
    display: flex;
}

.floating-audio-window .controls-bar {
    justify-content: flex-end;
}

.send-button {
    background: var(--primary-glass);
    color: white;
}

.send-button:hover {
    background: rgba(0, 122, 255, 1);
}

.close-button {
    background: var(--dark-glass);
    border: none;
    color: #fff;
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.pinned {
    position: fixed;
    top: 20px;
    right: 80px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.pinned .menu-button {
    display: none;
}

#dateField {
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

.accordion {
    --bs-accordion-bg: transparent !important;
    --bs-accordion-border-color: rgba(255, 255, 255, 0.1);
    --bs-accordion-btn-color: #f5f5f7;
    --bs-accordion-active-color: #fff;
    --bs-accordion-active-bg: rgba(255, 255, 255, 0.05);
}

.accordion-button {
    border-radius: 15px !important;
}

.accordion-item {
    border: none !important;
}

.diary-card.accordion {
    padding: 0 !important;
    background: transparent;
    border: none;
}

.message-media {
    max-width: 200px;
    max-height: 200px;
    border-radius: 15px;
    margin-top: 10px;
}

.file-link {
    color: #58a6ff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(88, 166, 255, 0.2);
    padding: 5px 10px;
    border-radius: 10px;
}

.file-link:hover {
    text-decoration: none;
    background: rgba(88, 166, 255, 0.4);
}

/* Media Modal */
.modal-media {
    width: 100%;
    height: auto;
    border-radius: 15px;
}

@media (max-width: 600px) {
    .message-media {
        max-width: 100%;
        height: auto;
    }
}

.form-control,
.form-select {
    background: rgba(0, 0, 0, 0.2) !important;
    color: white !important;
    outline: none !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 15px;
}

.form-check-input {
    --bs-form-check-bg: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.form-control:focus,
.form-select:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.5) !important;
    border-color: rgba(0, 122, 255, 0.8);
}

.btn {
    border-radius: 12px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.btn-primary {
    background-color: var(--yuna);
    border-color: var(--yuna);
}

.btn-primary:hover {
    background-color: rgba(0, 158, 140, 0.8);
    border-color: rgba(0, 158, 140, 0.8);
}

.btn-secondary {
    background-color: var(--light-glass);
    border-color: var(--light-glass-border);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Styling for the chat history list */
#chatList {
    --bs-list-group-bg: transparent;
    /* Remove default Bootstrap background */
    --bs-list-group-border-color: transparent;
    /* Remove default Bootstrap border */
    border-radius: 20px;
    overflow: hidden;
    /* Ensures child elements respect the border-radius */
}

.list-group-item {
    background: var(--dark-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: #f5f5f7;
    padding: 1rem 1.25rem;
    margin-bottom: 8px;
    border-radius: 16px;
    transition: background-color 0.3s ease, transform 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Remove the default separator lines */
.list-group-item+.list-group-item {
    border-top-width: 1px;
}

.list-group-item:last-child {
    margin-bottom: 0;
}

.chat-name {
    font-weight: 500;
}

.list-group-item::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    padding-bottom: 200%;
    /* Maintain aspect ratio */
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0) 50%);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease-out, opacity 0.5s ease-out;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

.list-group-item:hover::before {
    transform: translate(calc(var(--x, 0) - 50%), calc(var(--y, 0) - 50%)) scale(1);
    opacity: 1;
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

/* Ensure content is above the pseudo-element */
.list-group-item>* {
    position: relative;
    z-index: 1;
}

.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 8px 10px 30px 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.input-area .input-group {
    width: 100%;
    display: flex;
    align-items: center;
    transition: background-color 0.3s ease;
    position: fixed;
    z-index: 1050;
    overflow-y: auto;
}

/* Style for when the app is in dark mode */
body.dark-mode .input-area .input-group {
    background: rgba(40, 40, 40, 0.7);
}

#messageInput {
    flex-grow: 1;
    /* Allow it to take up the remaining space */
    border: none;
    background: transparent;
    color: #000;
    /* Black text for light mode */
    font-size: 17px;
    padding: 8px 12px;
    outline: none;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

body.dark-mode #messageInput {
    color: #fff;
}

/* Placeholder text color */
#messageInput::placeholder {
    color: #8e8e93;
}

.send-button {
    width: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2) !important;
    color: #333;
    border: none;
    transition: transform 0.2s ease, background-color 0.2s ease;
    flex-shrink: 0;
    border-top-right-radius: 50% !important;
    border-bottom-right-radius: 50% !important;
    border-top-left-radius: 50% !important;
    border-bottom-left-radius: 50% !important;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.send-button.visible {
    transform: scale(1);
    opacity: 1;
}

.send-button i {
    font-size: 16px;
    margin-left: 2px;
}